<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row type="flex">
          <a-col>
            <a-button icon="plus" style="margin-right: 20px" type="primary" @click="openAdd()">新增</a-button>
            <a-divider style="margin-right: 20px" type="vertical" />
          </a-col>
          <a-col :md="5" :sm="7" style="margin-left: 15px">
            <a-form-item label="年份">
              <a-select v-model="queryParam.year" placeholder="请选择年份">
                <a-select-option v-for="(i,index) in yearList" :key="index" :value="i.key">{{ i.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
<!--          <a-col :md="5" :sm="7" style="margin-left: 15px">-->
<!--            <a-form-item label="类别">-->
<!--              <a-select v-model="queryParam.type" placeholder="请选择类别">-->
<!--                <a-select-option v-for="(i,index) in selectList" :key="index" :value="i.key">{{ i.name }}-->
<!--                </a-select-option>-->
<!--              </a-select>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col flex="auto" style="margin-left: 15px">
            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;margin-right: 20px">
              <a-button icon="search" style="margin-left: 10px" type="primary" @click="searchQuery">查询</a-button>
              <a-popover :overlayStyle="{background: 'white'}" placement="topLeft">
                <template slot="content">
                  <a-icon theme="twoTone" two-tone-color="#52c41a" type="exclamation-circle" /><span
                  style="margin-left: 5px">可以点击重置来重新筛选结果</span>
                </template>
                <a-button
                  icon="reload"
                  style="margin-left: 8px"
                  @click="searchReset"
                >重置</a-button>
              </a-popover>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <div>
      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        bordered
        rowKey="id"
        size="middle"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a-button style="margin-right: 10px" type="primary" @click="handleEdit(record)">
            编辑
          </a-button>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button>
                删除
              </a-button>
            </a-popconfirm>
        </span>
      </a-table>
<!--      <eng-consumption-modal ref="modalForm" @ok="modalFormOk"></eng-consumption-modal>-->
      <variety-carbon-modal ref="modalForm" @ok="modalFormOk"></variety-carbon-modal>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
import VarietyCarbonModal from '@views/dataVisualization/components/varietyCarbonModal'
const date = new Date()
const count = date.getFullYear() - 2015
const yearlist = []
for (let i = 0; i < count + 1; i++) {
  yearlist.push({
    name: date.getFullYear() - i,
    key: date.getFullYear() - i
  })
}
export default {
  name: 'varietyCarbonEmissions',
  components: { VarietyCarbonModal },
  mixins: [JeecgListMixin],
  data() {
    return {
      // queryParam: {
      //   month: null,
      // },
      // selectList: [
      //   { name: '煤品', key: '煤品' },
      //   { name: '油品', key: '油品' },
      //   { name: '天然气', key: '天然气' },
      //   { name: '净调入电', key: '净调入电' },
      // ],
      selectList: [
        { name: '农业', key: '农业' },
        { name: '工业', key: '工业' },
        { name: '建筑业', key: '建筑业' },
        { name: '建筑', key: '建筑' },
        { name: '交通', key: '交通' },
      ],
      yearList: yearlist,
      confirmLoading: false,
      title: '',
      visible: false,
      dataSource: [],
      form: this.$form.createForm(this),
      dialogStyle: {
        top: '100px'
        // right:"20px",
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
        {
          title: '年份',
          align: 'center',
          dataIndex: 'year',
          width: 120
        },
        {
          title: '工业',
          align: 'center',
          dataIndex: 'industryTotal',
        },
        {
          title: '建筑业',
          align: 'center',
          dataIndex: 'buildConstruction',
        },
        {
          title: '建筑',
          align: 'center',
          dataIndex: 'buildTotal',
        },
        {
          title: '交通',
          align: 'center',
          dataIndex: 'trafficTotal',
        },
        {
          title: '农业',
          align: 'center',
          dataIndex: 'farme',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 200,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/carbon/energyAnalysisTerritoryType/list',
        // list:'/carbon/energyAnalysisTerritoryType/getEnergyTerritoryType',
        delete: '/carbon/energyAnalysisTerritoryType/delete',
      }
    }
  },
  methods: {
    openAdd() {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    }
  }
}
</script>

<style scoped>

</style>